package com.woniu.service.impl;

import com.woniu.dao.PreOrderMapper;
import com.woniu.pojo.PreOrder;
import com.woniu.service.OrderService;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class OderServiceImpl implements OrderService {
    @Autowired
    private PreOrderMapper preOrderMapper;
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @Override
    public void createorder(PreOrder preOrder) {
        preOrder.setStatus("待支付");
        CorrelationData data=new CorrelationData();
        data.setId(preOrder.getNum());
        Map map =new HashMap();
        map.put("uid",preOrder.getUid());
        map.put("puId",preOrder.getPuId());
        map.put("muId",preOrder.getMuId());
        map.put("name",preOrder.getName());
        map.put("location",preOrder.getLocation());
        map.put("num",preOrder.getNum());
        map.put("createtime",preOrder.getCreatetime());
        map.put("starttime",preOrder.getStarttime());
        map.put("endtime",preOrder.getEndtime());
        map.put("money",preOrder.getMoney());
        map.put("cash",preOrder.getCash());
        map.put("method",preOrder.getMethod());
        map.put("status",preOrder.getStatus());
        map.put("mark",preOrder.getMark());
        rabbitTemplate.convertAndSend("horder-exchange","order",map,data);
    }
}
